package client;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class LoginPanel extends JPanel{
	
	private JTextField user;
	private JPasswordField pwd;

	public LoginPanel(Client client) {
		setLayout(new BorderLayout());
		JPanel login = new JPanel(new GridLayout(5,1));
		JLabel userName = new JLabel("Username", JLabel.CENTER);
		user = new JTextField();
		JLabel password = new JLabel("Password", JLabel.CENTER);
		pwd = new JPasswordField();
		login.add(userName);
		login.add(user);
		login.add(password);
		login.add(pwd);
		JButton loginButton = new JButton("Login");
		login.add(loginButton);
		loginButton.addActionListener(client);
		add(login, BorderLayout.NORTH);
		Dimension d = new Dimension(200,200);
		setSize(d);
		setPreferredSize(d);
		setLocation(client.getWidth()/2-this.getWidth()/2, 0);
	}
	
	public User getUser(){
		return new User(user.getText(), pwd.getText(), "something@gmail.com");
	}

}
